package twi.result;

import java.util.ArrayList;
import java.util.List;

import twi.query.Query;
import twi.result.graph.GraphFactory;
import twi.result.graph.RGraph;
import twi.result.table.RTable;

import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.rdf.model.RDFNode;

public class DefaultResult implements QueryResult {

	RGraph graph = null;
	RTable table = null;

	public DefaultResult(Query qr, ResultSet rs) {
		this.table = new RTable(rs, qr);
		this.graph = GraphFactory.createGraph(table);
	}

	@Override
	public RGraph asGraph() {
		return graph;
	}

	@Override
	public RTable asTable() {
		return table;
	}

	@Override
	public List<String> getVariableNames() {
		return this.table.getVariableNames();
	}

	@Override
	public ArrayList<RDFNode> getVariableList(String key) {
		return this.table.getVariables(key);
	}

}
